import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/shangGong',
    component: () => import('@/views/other/shangGong'),
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example',
  //   name: 'Example',
  //   meta: { title: '班级学员管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'classes',
  //       name: 'Classes',
  //       component: () => import('@/views/classes'),
  //       meta: { title: '班级管理', icon: 'el-icon-menu' }
  //     },
  //     {
  //       path: 'student',
  //       name: 'Student',
  //       component: () => import('@/views/student'),
  //       meta: { title: '学员管理', icon: 'el-icon-user-solid' }
  //     }
  //   ]
  // },
  {
    path: '/system',
    component: Layout,
    redirect: '/system',
    name: 'System',
    meta: { title: '系统信息管理', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'dept',
        name: 'Dept',
        component: () => import('@/views/dept'),
        meta: { title: '部门管理', icon: 'el-icon-menu' }
      },
      {
        path: 'emp',
        name: 'Emp',
        component: () => import('@/views/emp'),
        meta: { title: '员工管理', icon: 'el-icon-user-solid' }
      }
    ]
  },
  {
    path: '/quality',
    component: Layout,
    redirect: '/quality',
    name: 'quality',
    meta: { title: '质量检测', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'conn',
        name: 'conn',
        component: () => import('@/views/conn'),
        meta: { title: '质量检测交接', icon: 'el-icon-menu' }
      },

    ]
  },
  {
    path: '/performance',
    component: Layout,
    redirect: '/performance',
    name: 'performance',
    meta: { title: '绩效管理', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'conn',
        name: 'conn',
        component: () => import('@/views/performance'),
        meta: { title: '绩效管理', icon: 'el-icon-menu' }
      },

    ]
  },

  // {
  //   path: '/report',
  //   component: Layout,
  //   redirect: '/report',
  //   name: 'Report',
  //   meta: { title: '数据统计管理', icon: 'el-icon-s-tools' },
  //   children: [
  //     {
  //       path: 'emp-report',
  //       name: 'emp-report',
  //       component: () => import('@/views/emp-report'),
  //       meta: { title: '员工信息统计', icon: 'el-icon-s-data' }
  //     },
  //     {
  //       path: 'student-report',
  //       name: 'student-report',
  //       component: () => import('@/views/student-report'),
  //       meta: { title: '学员信息统计', icon: 'el-icon-s-data' }
  //     }
  //   ]
  // },
  {
    path: '/produce',
    component: Layout,
    redirect: '/produce',
    name: 'Produce',
    meta: { title: '生产管理', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'proOrder',
        name: 'proOrder',
        component: () => import('@/views/produce/proOrder'),
        meta: { title: '生产工单', icon: 'el-icon-s-data' }
      },
      {
        path: 'proReport',
        name: 'proReport',
        component: () => import('@/views/produce/proReport'),
        meta: { title: '生产报工', icon: 'el-icon-s-data' }
      },
      {
        path: 'process',
        name: 'process',
        component: () => import('@/views/produce/process'),
        meta: { title: '工序管理', icon: 'el-icon-s-data' }
      },
      {
        path: 'craft',
        name: 'craft',
        component: () => import('@/views/produce/craft'),
        meta: { title: '工艺流程', icon: 'el-icon-s-data' }
      },

    ]
  },
  {
    path: '/monitor',
    component: Layout,
    redirect: '/monitor',
    name: 'Monitor',
    meta: { title: '实时监控', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'empMonitor',
        name: 'empMonitor',
        component: () => import('@/views/monitor/empMonitor'),
        meta: { title: '员工实时监控', icon: 'el-icon-s-data' }
      },

      {
        path: 'shebeiMonitor',
        name: 'shebeiMonitor',
        component: () => import('@/views/monitor/shebeiMonitor'),
        meta: { title: '设备实时监控', icon: 'el-icon-s-data' }
      },


    ]
  },
  {
    path: '/other',
    component: Layout,
    redirect: '/other',
    name: 'other',
    meta: { title: '其他', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'shangGongLogin',
        name: 'shangGongLogin',
        component: () => import('@/views/other/shangGongLogin.vue'),
        meta: { title: '上工登录', icon: 'el-icon-menu' }
      },
      {
        path: 'xiaGongLogin',
        name: 'xiaGongLogin',
        component: () => import('@/views/other/xiaGongLogin.vue'),
        meta: { title: '下工登录', icon: 'el-icon-menu' }
      },
      {
        path: 'shangGong',
        name: 'shangGong',
        component: () => import('@/views/other/shangGongPro.vue'),
        meta: { title: '上工', icon: 'el-icon-menu' }
      },
      {
        path: 'xiaGong',
        name: 'xiaGong',
        component: () => import('@/views/other/xiaGong.vue'),
        meta: { title: '下工', icon: 'el-icon-menu' }
      },
      {
        path: 'dayplan',
        name: 'dayplan',
        component: () => import('@/views/dayplan/index.vue'),
        meta: { title: '今日工作', icon: 'el-icon-menu' }
      },
      {
        path: 'dayplanLogin',
        name: 'dayplanLogin',
        component: () => import('@/views/dayplan/dayplanLogin.vue'),
        meta: { title: '今日工作登录', icon: 'el-icon-menu' }
      },
      {
        path: 'xiaGongResult',
        name: 'xiaGongResult',
        component: () => import('@/views/other/xiaGongResult.vue'),
        meta: { title: '下工结果页', icon: 'el-icon-menu' }
      },
      {
        path: 'shangGongResult',
        name: 'shangGongResult',
        component: () => import('@/views/other/shangGongResult.vue'),
        meta: { title: '上工结果页', icon: 'el-icon-menu' }
      },

    ]
  },


  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
